package com.giao.controller;

import com.giao.pojo.Users;
import com.giao.service.UsersService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;


import javax.annotation.Resource;

@Controller
public class LoginUsers {
    @Resource
    private UsersService usersService;

    @RequestMapping("/gotoLogin")
    public String gotoLogin() {
        return "login";
    }

    /*登录*/
    @RequestMapping("/login")
    public String login(Users users, Model model) {
        Users u = usersService.login(users);
        if (u == null) {
            return "login";
        }
        model.addAttribute("username", u.getUsername());
        return "home/fmain";
    }

}


